import sys, pygame
pygame.init()

# some constants:
size = width, height = 1200, 700
speed = [1, 5]
acceleration_due_to_gravity = -1
friction = 1

black = 0, 0, 0

screen = pygame.display.set_mode(size)

ball = pygame.image.load("x.bmp")
ballrect = ball.get_rect()

while True:
    for event in pygame.event.get():
        if event.type == pygame.QUIT: 
            sys.exit()
        
    ballrect = ballrect.move(speed)
    if (ballrect.left % 10 == 0):
        speed[1] = speed[1] + acceleration_due_to_gravity
    if (ballrect.left % 100 == 0):
        if speed[1] < 0:
            speed[1] = speed[1] +1
        if speed[1] > 0:
            speed[1] = speed[1] - 1
    
    if ballrect.left < 0 or ballrect.right > width:
        speed[0] = -speed[0]
    if ballrect.top < 0 or ballrect.bottom > height:
        speed[1] = -speed[1]
    
    # the screen is repainted at every frame
    screen.fill(black)
    
    # here we move the ball
    screen.blit(ball, ballrect)
    
    # makes everything drawn and visible
    pygame.display.flip()
